Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p-from-callback

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-from-callback

Map a callback to a promise

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

p-from-callback

Build Status npm package Coverage Status

Map node-style callback to a promise

Install

$ npm install p-from-callback

Features

  • pure esm module
  • typescript types
  • supports multiple return values
  • 100% test coverage

Usage

import { readFile } from 'node:fs';
import fromCallback from 'p-from-callback';

fromCallback(cb => readFile("foo.txt", cb)).then(buf => buf.toString('utf8'));
fromCallback(cb => cb(undefined, "foo", "bar"), true)
    .then([foo, bar] => foo === "foo" && bar === "bar");

API

fromCallback<R>((cb: (err: any, res: R)): any): Promise<R>
fromCallback<R>((cb: (err: any, ...res: R[])): any, true): Promise<R[]>

Takes a callback resolver and returns a promise to the resolved value, or array of values when multi = true.

License

See the LICENSE file for license rights and limitations (MIT).

Keywords

FAQs

Package last updated on 01 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc